package com.tjec.project.msg.mobset.sms;

import com.tjec.project.msg.mobset.bean.DataObjectBean;
import com.tjec.project.msg.mobset.bean.msmResultBean;
import com.tjec.project.msg.mobset.factory.DataObjectFactory;
import com.tjec.project.msg.tempuri.MobsetApiSoap;
import com.tjec.project.msg.tempuri.holders.ArrayOfSmsReportListHolder;
import com.tjec.project.msg.util.MD5;

import java.net.URL;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.rpc.holders.LongHolder;
import javax.xml.rpc.holders.StringHolder;


public class sms_GetReport {
	private static long corpID;      					//��ҵID
	private static String loginName;					//��¼�ʺ�
	private static String password;						//���룬MD5(CorpID+�ʺ�����+TimeStamp)
	private static	URL url;
	private static String timeStamp = "1105203910";		//ʱ�����MMDDHHMMSS������ʱ����),��0514094912
	private static StringHolder errMsg;					//������Ϣ�����ڷ��غ������ý������������
	private static ArrayOfSmsReportListHolder smsReportList;//����״̬�����б����ڷ��ؽ��յ��Ķ���״̬���档ÿ����෵��50��״̬���档
	private static LongHolder count;					//���ú����ķ���ֵ�����Ͷ��ţ����ض���ID(SmsID)
	
	public static msmResultBean getReport(String reportList){
		
		Date now = new Date(); 
		SimpleDateFormat dateFormat = new SimpleDateFormat("MMddHHmmss");//���Է�����޸����ڸ�ʽ
		timeStamp = dateFormat.format(now); 
		System.out.println(timeStamp); 
		//���ʵ��������
		//MobsetApiSoap mobset = DataObjectFactory.getMobsetApi();
		errMsg = new StringHolder();
		count = new LongHolder();
		msmResultBean msmBean = new msmResultBean();
		smsReportList = new ArrayOfSmsReportListHolder();
		
		//��ȡ�ʺ���Ϣ
		DataObjectBean bean = DataObjectFactory.getInstance();
		corpID = new Long(bean.getCordId());
		loginName = bean.getUserName();
		password = bean.getPasswd();
		try
		{
		url=new URL(bean.getServerIP());
		}
		catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        MobsetApiSoap mobset = DataObjectFactory.getMobsetApi(url);
		//MD5�������
		MD5 md5 = new MD5();
		password = md5.getMD5ofStr(corpID+password+timeStamp);
		
		try {
			mobset.sms_GetReport(corpID, loginName, password,timeStamp,count,errMsg, smsReportList);
			msmBean.setErrMsg(errMsg);
			if(smsReportList != null)
			msmBean.setSmsReportList(smsReportList);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msmBean;
	}
}
